<template>
  <div class="container">
    <h3 class="title">
      <svg-icon icon-class="nested" class="title-icon" />收款账号管理
    </h3>

    <el-card>
      <div slot="header">
        <span>编辑账号</span>
      </div>
      <el-form :model="form" label-position="left" label-width="120px">
        <el-form-item
          label="商户编码:"
          :rules="[
      { required: true, message: '请输入', trigger: 'blur' }
    ]"
        >
          <el-input v-model="form.no" style="width:50%;" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="入账银行:">{{form.bankOfAccount}}</el-form-item>
        <el-form-item>
          <el-button type="primary" size="small" @click="onSubmit">确定</el-button>
          <el-button size="small" @click="onCancle">取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import { editMoney } from "@/api/money";
export default {
  name: "editManage",
  data() {
    return {
      form: {
        no: "",
        bankOfAccount: "",
        id: ""
      }
    };
  },
  mounted() {
    this.form = JSON.parse(localStorage.detail);
  },
  methods: {
    onSubmit() {
      if (this.form.no == "") {
        this.$message({
          type: "warning",
          message: "请输入商户编号"
        });
      }
      editMoney(this.form.id, this.form.no).then(res => {
        if (res.code == 200) {
          this.$message({
            type: "success",
            message: "编辑成功"
          });
          this.$router.go(-1);
          document
            .querySelector(".tags-view-item.active>span.el-icon-close")
            .click();
        } else {
          this.$message({
            message: res.message,
            type: "warning"
          });
        }
      });
    },
    onCancle() {
      this.$router.go(-1);
      document
        .querySelector(".tags-view-item.active>span.el-icon-close")
        .click();
    }
  }
};
</script>

<style lang="scss" scoped>
.container {
  padding: 20px;
  background-color: rgb(240, 242, 245);
  position: relative;
  .title {
    font-size: 14px;
    font-weight: 400;
    .title-icon {
      font-size: 14px;
      display: inline-block;
      margin-right: 5px;
    }
  }
  /deep/ .el-card__header {
    border: 0 none;
  }
}
.title-small {
  font-size: 14px;
}

.money {
  color: #409eff;
}
</style>
